package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);

    Page<DishVO> queryDishList(DishPageQueryDTO dishPageQueryDTO);

    void deleteDish(List<Long> ids);

    @Select("select status from dish where id = #{id}")
    Integer getStatustById(Long id);

    @Select("select * from dish where id = #{id}")
    Dish getDishById(Long id);

    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    @Select("select * from dish where category_id = #{categoryId} and status = 1")
    List<Dish> queryDishByCategoryId(Long categoryId);
}
